package lb.io.client;

import io.grpc.NameResolver;
import io.grpc.NameResolver.Args;
import io.grpc.NameResolverProvider;

import java.net.URI;

public class LocalNameResolverProvider extends NameResolverProvider {
    private final String[] endpoints;

    public LocalNameResolverProvider(String[] endpoints) {
        this.endpoints = endpoints;
    }

    @Override
    protected boolean isAvailable() {
        return true;
    }

    @Override
    protected int priority() {
        return 5;
    }

    @Override
    public NameResolver newNameResolver(URI targetUri, Args args) {
        return new LocalNameResolver(endpoints);
    }

    @Override
    public String getDefaultScheme() {
        return "apiserver";
    }
}
